package com.ncp.servlet.comment;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ncp.model.biz.comment.CommentCl;
import com.ncp.model.biz.util.Character;

public class AdminCommentServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		int id=Integer.parseInt(request.getParameter("cid"));
		String flag=request.getParameter("flag");
		String name=(String)request.getSession().getAttribute("userLoginName");
		int level=new CommentCl().getUserInfo(name).getLevelID();
	/*	System.out.println(level);
		System.out.println(name);*/
		
			
			if(flag.equals("delete")){
				if(new CommentCl().deleteComment(id)){
					response.sendRedirect("pages/comment/admin/success.jsp");
				}else response.sendRedirect("pages/comment/admin/error.jsp");
			}if(flag.equals("update")){
				String comment=request.getParameter("comment");
				System.out.println(comment);
				if(new CommentCl().updateComment(id, comment)){
					response.sendRedirect("pages/comment/admin/success.jsp");
				}else response.sendRedirect("pages/comment/admin/error.jsp");
			}
		
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doGet(request, response);
	}

}
